<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/12/18/018
 * Time: 23:27
 * by 景
 */
include_once './lib/fun.php';
if(!checkLogin())
{
    msg(2,'亲，您还没有登录，请登录','login.php');
}
//校验url中商品的id
$goodsId = isset($_GET['id']) && is_numeric($_GET['id'])? intval($_GET['id']):'';
//如果id不存在，跳转到商品页面
if(!$goodsId)
{
    msg(2,'参数非法','index.php');
}
//根据商品id查询商品信息
$con = mysqlInit('127.0.0.1','root','root','imooc');
$sql = "SELECT * FROM `im_goods` WHERE `id` ={$goodsId}";
$obj = mysqli_query($con,$sql);
//当根据id查询商品信息为空时  跳转到商品列表页
if(!$goods = mysqli_fetch_assoc($obj))
{
    msg(2,'商品不存在','index.php');
}

//删除处理
$sql = "DELETE FROM `im_goods` WHERE `id` = {$goodsId} LIMIT 1";
if($result = mysqli_query($con,$sql))
{
    msg(1,'删除成功','index.php');
}else{
    msg(2,'删除失败','index.php');
}
